//
//  WaterFlowCollectionViewCell.m
//  CollectionPictures
//
//  Created by ooops on 12/23/16.
//  Copyright © 2016 ya. All rights reserved.
//

#import "WaterFlowCollectionViewCell.h"
#import "AXFShoppingButtonView.h"

@interface WaterFlowCollectionViewCell ()

@property (nonatomic, strong)  AXFShoppingButtonView  *oprationShoppingCar;   /** 购物车加减按钮 */
@property (nonatomic, strong)  UILabel *lblNotingTip;   /** 商城缺货标签 */

@end

@implementation WaterFlowCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.contentView addSubview:self.oprationShoppingCar];
    [self.contentView addSubview:self.lblNotingTip];
    [self.oprationShoppingCar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self);
        make.bottom.equalTo(self).offset(-5);
    }];
    [self.lblNotingTip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self).offset(-8);
        make.bottom.equalTo(self).offset(-5);
    }];
    
    self.productImageView.image = SQUARESIZEPLACEHOLDER;
    //[self.vertivalButton setTitleEdgeInsets:UIEdgeInsetsMake(35, -40, 0, 0)];
    
    //[self.vertivalButton setImageEdgeInsets:UIEdgeInsetsMake(-10, 10, 0, 0)];
    
}

- (AXFShoppingButtonView *)oprationShoppingCar {
    if(_oprationShoppingCar == nil) {
        _oprationShoppingCar = nibView(@"AXFShoppingButtonView");
      
    }
    return _oprationShoppingCar;
}

- (UILabel *)lblNotingTip {
    if(_lblNotingTip == nil) {
        _lblNotingTip = [UILabel sj_createLabelWithText:@"补货中" fontSize:16 blod:YES textColor:[UIColor redColor]];
    }
    return _lblNotingTip;
}

- (void)setModel:(AXFDataModel *)model {
    if(model) {
        _model = model;
        [_productImageView sd_setImageWithURL:[self imageURLWithString:_model.imgURL] placeholderImage:SQUARESIZEPLACEHOLDER];
        _productName.text = model.name;
        _weightLabel.text = model.specifics;
        _sallPriceLabel.text = [NSString stringWithFormat:@"$%@",model.partner_price];
        
        NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.market_price] attributes:attribtDic];
        [_originSallPriceLabel setAttributedText:attribtStr];
        
        BOOL isHidden = model.number.intValue > 0 ? YES : NO;
        _oprationShoppingCar.hidden = !isHidden;
        _lblNotingTip.hidden = isHidden;
          [_oprationShoppingCar setValue:self.model forKey:@"model"];
    }
}

- (NSURL *)imageURLWithString:(NSString *)imageString {
    return [NSURL URLWithString:imageString];
}

@end
